package com.java.flowable.myflowable.controller;

import com.java.flowable.myflowable.tool.api.R;
import com.java.flowable.myflowable.service.IFlowInstanceService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 *
 */
@RestController
@RequestMapping("/flowable/instance")
public class FlowInstanceController {

    @Autowired
    private IFlowInstanceService flowInstanceService;

    /**
     *
     * @param procDefId
     * @param variables
     * @return
     */
    @PostMapping("/startByProcDefId/{procDefId}")
    @ApiOperation(value = "启动流程实例")
    public R<?> startById(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
                          @ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
        return R.data(flowInstanceService.startProcessInstanceById(procDefId, variables));

    }
}
